<?php

class Model {

	private static $conn = null;

	/**
	 * 得到数据库连接
	 *
	 * @author:thankwsx
	 */
	static function getConn() {
		if(!self::$conn) {
			try {
				$dbconfig = array("user"=>"root","pass"=>"","schema"=>"thankphp");
				$dsn = "mysql:dbname=".$dbconfig['schema'].";host=localhost";
				$user = $dbconfig['user'];
				$pass = $dbconfig['pass'];
				self::$conn = new PDO($dsn , $user , $pass);
				self::$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
			} catch(PDOException $e) {
				showHeader('Error');
				showError("Sorry, an error has occurred. Please try your request later\n".$e->getMessage());
			}
		}
		return self::$conn;
	}
}
?>